package com.xbongbong.saas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.saas.enums.business.OtherExpenseEnum;
import com.xbongbong.saas.enums.business.OtherIncomeEnum;
import com.xbongbong.saas.enums.business.PaySheetEnum;
import com.xbongbong.saas.enums.business.PaymentSheetEnum;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * 各种类型回款单、付款单、其他收入单、其他支出单的字段处理
 * 更改该枚举，需同步处理FundHelp内的handlePaymentSheet方法
 * @author zcp
 * @version v1.0
 * @date 19/11/13 013 16:56
 * @update 20/2/24 by zcp 改造使其兼容付款单
 * @update 21/5/25 by zcp 改造使其兼容其他收入单、其他支出单
 * @since v1.0
 */
public class SheetAssembleEnum {
    /**
     * 要移除的字段
     */
    private static final int OPERATE_REMOVE = 1;
    /**
     * 需要更新信息的字段
     */
    private static final int OPERATE_UPDATE = 2;

    /**
     * 预收款核销：只保留部分系统字段，【自定义字段要全部移除-isRedundant=1的都移除】
     */
    public @Getter enum WriteOffPrepayment {
        //预收款核销，要移除的字段：回款金额、收款账户、支付方式、扩展信息、备注、附近、【自定义字段】
        AMOUNT(PaymentSheetEnum.AMOUNT.getAttr(), PaySheetEnum.AMOUNT.getAttr(), OPERATE_REMOVE, null, null, null),
        FUND_ACCOUNT(PaymentSheetEnum.FUND_ACCOUNT.getAttr(), PaySheetEnum.FUND_ACCOUNT.getAttr(), OPERATE_REMOVE, null, null, null),
        PAY_METHOD(PaymentSheetEnum.PAY_METHOD.getAttr(), PaySheetEnum.PAY_TYPE.getAttr(), OPERATE_REMOVE, null, null, null),
        SYSTEM_INFO(PaymentSheetEnum.SYSTEM_INFO.getAttr(), PaySheetEnum.SYSTEM_INFO.getAttr(), OPERATE_REMOVE, null, null, null),
        MEMO(PaymentSheetEnum.MEMO.getAttr(), PaySheetEnum.MEMO.getAttr(), OPERATE_REMOVE, null, null, null),
        FILE(PaymentSheetEnum.FILE.getAttr(), PaySheetEnum.FILE.getAttr(), OPERATE_REMOVE, null, null, null),
        //预收款核销，要修改的字段：核销金额（要在新建编辑界面，且必填）、核销日期
        WRITE_OFF_AMOUNT(PaymentSheetEnum.WRITE_OFF_AMOUNT.getAttr(), PaySheetEnum.WRITE_OFF_AMOUNT.getAttr(), OPERATE_UPDATE, "enum.paymentSheet.attrName.write_off_amount", ShowTypeEnum.ALL.getCode(), 1),
        PAYMENT_TIME(PaymentSheetEnum.PAYMENT_TIME.getAttr(), PaySheetEnum.REAL_PAY_TIME.getAttr(), OPERATE_UPDATE, "enum.sheetAssemble.writeOffPrepayment.name.payment_time", PaymentSheetEnum.PAYMENT_TIME.getShowType(), PaymentSheetEnum.PAYMENT_TIME.getRequired()),
        ;
        /**
         * 回款单字段英文名
         */
        private String attrPaymentSheet;
        /**
         * 付款单字段英文名
         */
        private String attrPaySheet;
        /**
         * 1要移除，2修改（可能名称、是否必填等要修改）
         */
        private Integer operate;
        /**
         * 字段名
         */
        private String name;
        /**
         * 字段在各个界面（新建、编辑、列表、详情）的展现形式
         * 详见
         *
         * @see ShowTypeEnum
         */
        private Integer showType;
        /**
         * 字段是否必填
         * 1：必填
         * 0：不必填
         */
        private Integer required;

        WriteOffPrepayment(String attrPaymentSheet, String attrPaySheet, Integer operate, String name, Integer showType, Integer required) {
            this.attrPaymentSheet = attrPaymentSheet;
            this.attrPaySheet = attrPaySheet;
            this.name = name;
            this.operate = operate;
            this.showType = showType;
            this.required = required;
        }

        public String getName() {
            return I18nMessageUtil.getMessage(name);
        }

        /**
         * 得到要移除的字段名
         * @return java.util.List<java.lang.String>
         * @author zcp
         * @date 19/11/13 013 21:52
         * @update 19/11/13 013 21:52
         * @since v1.0
         * @version v1.0
         */
        public static List<String> removeAttr(XbbRefTypeEnum xbbRefTypeEnum) {
            List<String> removeAttrList = new ArrayList<>();
            if (Objects.equals(xbbRefTypeEnum, XbbRefTypeEnum.PAY_SHEET)) {
                for (WriteOffPrepayment cache : values()) {
                    if (Objects.equals(cache.operate, OPERATE_REMOVE)) {
                        removeAttrList.add(cache.attrPaySheet);
                    }
                }
            } else {
                for (WriteOffPrepayment cache : values()) {
                    if (Objects.equals(cache.operate, OPERATE_REMOVE)) {
                        removeAttrList.add(cache.attrPaymentSheet);
                    }
                }
            }
            return removeAttrList;
        }

        /**
         * 得到要更新的字段对应关系map
         * @return java.util.Map<java.lang.String,com.xbongbong.saas.enums.SheetAssembleEnum.WriteOffPrepayment>
         * @author zcp
         * @date 19/11/13 013 22:10
         * @update 19/11/13 013 22:10
         * @since v1.0
         * @version v1.0
         */
        public static Map<String, WriteOffPrepayment> updateAttr(XbbRefTypeEnum xbbRefTypeEnum) {
            //attrPaymentSheet-要更新的字段枚举
            Map<String, WriteOffPrepayment> updateMap = new HashMap<>(values().length);
            if (Objects.equals(xbbRefTypeEnum, XbbRefTypeEnum.PAY_SHEET)) {
                for (WriteOffPrepayment cache : values()) {
                    if (Objects.equals(cache.operate, OPERATE_UPDATE)) {
                        updateMap.put(cache.attrPaySheet, cache);
                    }
                }
            } else {
                for (WriteOffPrepayment cache : values()) {
                    if (Objects.equals(cache.operate, OPERATE_UPDATE)) {
                        updateMap.put(cache.attrPaymentSheet, cache);
                    }
                }
            }
            return updateMap;
        }
    }

    /**
     * 预收款：移除三个系统字段
     */
    public @Getter enum Prepayment {
        // 预收款，目前只需要移除字段
        CONTRACT(PaymentSheetEnum.CONTRACT.getAttr(), PaySheetEnum.LINK_PURCHASE.getAttr(), OPERATE_REMOVE),
        CONTRACT_LINK_TEXT(PaymentSheetEnum.CONTRACT_LINK_TEXT.getAttr(), PaySheetEnum.PURCHASE_LINK_TEXT.getAttr(), OPERATE_REMOVE),
        PAYMENT(PaymentSheetEnum.PAYMENT.getAttr(), PaySheetEnum.PAY_PLAN.getAttr(), OPERATE_REMOVE),
        PAYMENT_LINK_TEXT(PaymentSheetEnum.PAYMENT_LINK_TEXT.getAttr(), PaySheetEnum.PAY_PLAN_LINK_TEXT.getAttr(), OPERATE_REMOVE),
        BELONG_ID(PaymentSheetEnum.BELONG_ID.getAttr(), PaySheetEnum.BELONG_ID.getAttr(), OPERATE_REMOVE),
        PAYMENT_TASK(PaymentSheetEnum.PAYMENT_TASK.getAttr(), "", OPERATE_REMOVE),
        PAYMENT_TASK_LINK_TEXT(PaymentSheetEnum.PAYMENT_TASK_LINK_TEXT.getAttr(), "", OPERATE_REMOVE),
        ;
        /**
         * 回款单字段英文名
         */
        private String attrPaymentSheet;
        /**
         * 付款单字段英文名
         */
        private String attrPaySheet;
        /**
         * 1要移除，2修改（可能名称、是否必填等要修改）
         */
        private Integer operate;

        Prepayment(String attrPaymentSheet, String attrPaySheet, Integer operate) {
            this.attrPaymentSheet = attrPaymentSheet;
            this.attrPaySheet = attrPaySheet;
            this.operate = operate;
        }

        /**
         * 得到要移除的字段名
         * @return java.util.List<java.lang.String>
         * @author zcp
         * @date 19/11/13 013 21:52
         * @update 19/11/13 013 21:52
         * @since v1.0
         * @version v1.0
         */
        public static List<String> removeAttr(XbbRefTypeEnum xbbRefTypeEnum) {
            List<String> removeAttrList = new ArrayList<>();
            if (Objects.equals(xbbRefTypeEnum, XbbRefTypeEnum.PAY_SHEET)) {
                for (Prepayment cache : values()) {
                    if (Objects.equals(cache.operate, OPERATE_REMOVE) && !Objects.equals(cache.attrPaySheet, "")) {
                        removeAttrList.add(cache.attrPaySheet);
                    }
                }
            } else {
                for (Prepayment cache : values()) {
                    if (Objects.equals(cache.operate, OPERATE_REMOVE)) {
                        removeAttrList.add(cache.attrPaymentSheet);
                    }
                }
            }
            return removeAttrList;
        }
    }

    /**
     * 红冲已核销、红冲预收款核销。
     * 且这两种类型回款单在新建编辑时展示的字段完全一致，因此这两种类型回款单只建一个枚举
     */
    public @Getter enum RedWriteOff {
        //移除完成回款计划字段
        PAYMENT_TASK(PaymentSheetEnum.PAYMENT_TASK.getAttr(), "", OPERATE_REMOVE, "", "", null),
        PAYMENT_TASK_LINK_TEXT(PaymentSheetEnum.PAYMENT_TASK_LINK_TEXT.getAttr(), "", OPERATE_REMOVE, "", "", null),
        //关联原始回款单，显示到新建、编辑、详情
        RED_SHEET(PaymentSheetEnum.RED_SHEET.getAttr(), PaySheetEnum.ORIGIN_ID.getAttr(), OPERATE_UPDATE, "enum.paymentSheet.attrName.red_sheet", "enum.paySheet.attrName.origin_id", ShowTypeEnum.EDIT_DETAIL.getCode()),
        // 红冲已核销、红冲预收款核销，名称修改
        AMOUNT(PaymentSheetEnum.AMOUNT.getAttr(), PaySheetEnum.AMOUNT.getAttr(), OPERATE_UPDATE, "enum.sheetAssemble.redWriteOff.name.amount", "enum.sheetAssemble.redWriteOff.namePay.amount", PaymentSheetEnum.AMOUNT.getShowType()),
        PAYMENT_TIME(PaymentSheetEnum.PAYMENT_TIME.getAttr(), PaySheetEnum.REAL_PAY_TIME.getAttr(), OPERATE_UPDATE, "enum.sheetAssemble.redWriteOff.name.payment_time", "enum.sheetAssemble.redWriteOff.namePay.payment_time", PaymentSheetEnum.PAYMENT_TIME.getShowType()),
        FUND_ACCOUNT(PaymentSheetEnum.FUND_ACCOUNT.getAttr(), PaySheetEnum.FUND_ACCOUNT.getAttr(), OPERATE_UPDATE, "enum.sheetAssemble.redWriteOff.name.fund_account", "enum.sheetAssemble.redWriteOff.namePay.fund_account", PaymentSheetEnum.FUND_ACCOUNT.getShowType()),
        ;
        /**
         * 回款单字段英文名
         */
        private String attrPaymentSheet;
        /**
         * 付款单字段英文名
         */
        private String attrPaySheet;
        /**
         * 1要移除，2修改（可能名称、是否必填等要修改）
         */
        private Integer operate;
        /**
         * 字段名
         */
        private String name;
        /**
         * 付款单内的字段名
         */
        private String namePay;
        /**
         * 字段在各个界面（新建、编辑、列表、详情）的展现形式
         * 详见
         *
         * @see ShowTypeEnum
         */
        private Integer showType;

        RedWriteOff(String attrPaymentSheet, String attrPaySheet, Integer operate, String name, String namePay, Integer showType) {
            this.attrPaymentSheet = attrPaymentSheet;
            this.attrPaySheet = attrPaySheet;
            this.name = name;
            this.namePay = namePay;
            this.operate = operate;
            this.showType = showType;
        }

        public String getName() {
            return I18nMessageUtil.getMessage(name);
        }

        public String getNamePay() {
            return I18nMessageUtil.getMessage(namePay);
        }
        /**
         * 得到要更新的字段对应关系map
         * @return java.util.Map<java.lang.String,com.xbongbong.saas.enums.SheetAssembleEnum.RedWriteOff>
         * @author zcp
         * @date 19/11/14 014 10:19
         * @update 19/11/14 014 10:19
         * @since v1.0
         * @version v1.0
         */
        public static Map<String, RedWriteOff> updateAttr(XbbRefTypeEnum xbbRefTypeEnum) {
            //attrPaymentSheet-要更新的字段枚举
            Map<String, RedWriteOff> updateMap = new HashMap<>(values().length);
            if (Objects.equals(xbbRefTypeEnum, XbbRefTypeEnum.PAY_SHEET)) {
                for (RedWriteOff cache : values()) {
                    if (Objects.equals(cache.operate, OPERATE_UPDATE)) {
                        updateMap.put(cache.attrPaySheet, cache);
                    }
                }
            } else {
                for (RedWriteOff cache : values()) {
                    if (Objects.equals(cache.operate, OPERATE_UPDATE)) {
                        updateMap.put(cache.attrPaymentSheet, cache);
                    }
                }
            }
            return updateMap;
        }
        /**
         * 得到要移除的字段名
         * @param xbbRefTypeEnum
         * @return java.util.List<java.lang.String>
         * @author zcp
         * @since v1.0
         * @version v1.0
         */
        public static List<String> removeAttr(XbbRefTypeEnum xbbRefTypeEnum) {
            List<String> removeAttrList = new ArrayList<>();
            if (Objects.equals(xbbRefTypeEnum, XbbRefTypeEnum.PAY_SHEET)) {
                for (RedWriteOff cache : values()) {
                    if (Objects.equals(cache.operate, OPERATE_REMOVE) && !Objects.equals(cache.attrPaySheet, "")) {
                        removeAttrList.add(cache.attrPaySheet);
                    }
                }
            } else {
                for (RedWriteOff cache : values()) {
                    if (Objects.equals(cache.operate, OPERATE_REMOVE)) {
                        removeAttrList.add(cache.attrPaymentSheet);
                    }
                }
            }
            return removeAttrList;
        }
    }

    /**
     * 红冲预收款核销(退到余额)
     * 且这两种类型回款单在新建编辑时展示的字段完全一致，因此这两种类型回款单只建一个枚举
     */
    public @Getter enum RedWriteOffBalance {
        //移除完成回款计划、回款金额字段
        PAYMENT_TASK(PaymentSheetEnum.PAYMENT_TASK.getAttr(), "", OPERATE_REMOVE, "", "", null, null),
        PAYMENT_TASK_LINK_TEXT(PaymentSheetEnum.PAYMENT_TASK_LINK_TEXT.getAttr(), "", OPERATE_REMOVE, "", "", null, null),
        AMOUNT(PaymentSheetEnum.AMOUNT.getAttr(), PaySheetEnum.AMOUNT.getAttr(), OPERATE_REMOVE, null, null, null, null),
        FUND_ACCOUNT(PaymentSheetEnum.FUND_ACCOUNT.getAttr(), PaySheetEnum.FUND_ACCOUNT.getAttr(), OPERATE_REMOVE, null, null, null, null),
        //关联原始回款单，显示到新建、编辑、详情
        RED_SHEET(PaymentSheetEnum.RED_SHEET.getAttr(), PaySheetEnum.ORIGIN_ID.getAttr(), OPERATE_UPDATE, "enum.paymentSheet.attrName.red_sheet", "enum.paySheet.attrName.origin_id", ShowTypeEnum.EDIT_DETAIL.getCode(), PaymentSheetEnum.RED_SHEET.getRequired()),
        // 红冲预收款核销(退到余额)，名称修改
        WRITE_OFF_AMOUNT(PaymentSheetEnum.WRITE_OFF_AMOUNT.getAttr(), PaySheetEnum.WRITE_OFF_AMOUNT.getAttr(), OPERATE_UPDATE, "enum.sheetAssemble.redWriteOff.name.amount", "enum.sheetAssemble.redWriteOff.namePay.amount", ShowTypeEnum.ALL.getCode(), 1),
        PAYMENT_TIME(PaymentSheetEnum.PAYMENT_TIME.getAttr(), PaySheetEnum.REAL_PAY_TIME.getAttr(), OPERATE_UPDATE, "enum.sheetAssemble.redWriteOff.name.payment_time", "enum.sheetAssemble.redWriteOff.namePay.payment_time", PaymentSheetEnum.PAYMENT_TIME.getShowType(), PaymentSheetEnum.PAYMENT_TIME.getRequired()),
        ;
        /**
         * 回款单字段英文名
         */
        private String attrPaymentSheet;
        /**
         * 付款单字段英文名
         */
        private String attrPaySheet;
        /**
         * 1要移除，2修改（可能名称、是否必填等要修改）
         */
        private Integer operate;
        /**
         * 字段名
         */
        private String name;
        /**
         * 付款单内的字段名
         */
        private String namePay;
        /**
         * 字段在各个界面（新建、编辑、列表、详情）的展现形式
         * 详见
         *
         * @see ShowTypeEnum
         */
        private Integer showType;
        /**
         * 字段是否必填
         * 1：必填
         * 0：不必填
         */
        private Integer required;

        RedWriteOffBalance(String attrPaymentSheet, String attrPaySheet, Integer operate, String name, String namePay, Integer showType, Integer required) {
            this.attrPaymentSheet = attrPaymentSheet;
            this.attrPaySheet = attrPaySheet;
            this.name = name;
            this.namePay = namePay;
            this.operate = operate;
            this.showType = showType;
            this.required = required;
        }

        public String getName() {
            return I18nMessageUtil.getMessage(name);
        }

        public String getNamePay() {
            return I18nMessageUtil.getMessage(namePay);
        }
        /**
         * 得到要更新的字段对应关系map
         * @return java.util.Map<java.lang.String,com.xbongbong.saas.enums.SheetAssembleEnum.RedWriteOff>
         * @author zcp
         * @date 19/11/14 014 10:19
         * @update 19/11/14 014 10:19
         * @since v1.0
         * @version v1.0
         */
        public static Map<String, RedWriteOffBalance> updateAttr(XbbRefTypeEnum xbbRefTypeEnum) {
            //attrPaymentSheet-要更新的字段枚举
            Map<String, RedWriteOffBalance> updateMap = new HashMap<>(values().length);
            if (Objects.equals(xbbRefTypeEnum, XbbRefTypeEnum.PAY_SHEET)) {
                for (RedWriteOffBalance cache : values()) {
                    if (Objects.equals(cache.operate, OPERATE_UPDATE)) {
                        updateMap.put(cache.attrPaySheet, cache);
                    }
                }
            } else {
                for (RedWriteOffBalance cache : values()) {
                    if (Objects.equals(cache.operate, OPERATE_UPDATE)) {
                        updateMap.put(cache.attrPaymentSheet, cache);
                    }
                }
            }
            return updateMap;
        }
        /**
         * 得到要移除的字段名
         * @param xbbRefTypeEnum
         * @return java.util.List<java.lang.String>
         * @author zcp
         * @since v1.0
         * @version v1.0
         */
        public static List<String> removeAttr(XbbRefTypeEnum xbbRefTypeEnum) {
            List<String> removeAttrList = new ArrayList<>();
            if (Objects.equals(xbbRefTypeEnum, XbbRefTypeEnum.PAY_SHEET)) {
                for (RedWriteOffBalance cache : values()) {
                    if (Objects.equals(cache.operate, OPERATE_REMOVE) && !Objects.equals(cache.attrPaySheet, "")) {
                        removeAttrList.add(cache.attrPaySheet);
                    }
                }
            } else {
                for (RedWriteOffBalance cache : values()) {
                    if (Objects.equals(cache.operate, OPERATE_REMOVE)) {
                        removeAttrList.add(cache.attrPaymentSheet);
                    }
                }
            }
            return removeAttrList;
        }
    }

    /**
     * 红冲预收款余额（原单：无，直接红冲预收款）
     */
    public @Getter enum RedPrepayment {
        // 红冲预收款余额，移除字段
        CONTRACT(PaymentSheetEnum.CONTRACT.getAttr(), PaySheetEnum.LINK_PURCHASE.getAttr(), OPERATE_REMOVE, null, null),
        CONTRACT_LINK_TEXT(PaymentSheetEnum.CONTRACT_LINK_TEXT.getAttr(), PaySheetEnum.PURCHASE_LINK_TEXT.getAttr(), OPERATE_REMOVE, null, null),
        PAYMENT(PaymentSheetEnum.PAYMENT.getAttr(), PaySheetEnum.PAY_PLAN.getAttr(), OPERATE_REMOVE, null, null),
        PAYMENT_LINK_TEXT(PaymentSheetEnum.PAYMENT_LINK_TEXT.getAttr(), PaySheetEnum.PAY_PLAN_LINK_TEXT.getAttr(), OPERATE_REMOVE, null, null),
        BELONG_ID(PaymentSheetEnum.BELONG_ID.getAttr(), PaySheetEnum.BELONG_ID.getAttr(), OPERATE_REMOVE, null, null),
        PAYMENT_TASK(PaymentSheetEnum.PAYMENT_TASK.getAttr(), "", OPERATE_REMOVE, null, null),
        PAYMENT_TASK_LINK_TEXT(PaymentSheetEnum.PAYMENT_TASK_LINK_TEXT.getAttr(), "", OPERATE_REMOVE, null, null),
        //修改字段信息
        AMOUNT(PaymentSheetEnum.AMOUNT.getAttr(), PaySheetEnum.AMOUNT.getAttr(), OPERATE_UPDATE, "enum.sheetAssemble.redPrepayment.name.amount", PaymentSheetEnum.AMOUNT.getShowType()),
        PAYMENT_TIME(PaymentSheetEnum.PAYMENT_TIME.getAttr(), PaySheetEnum.REAL_PAY_TIME.getAttr(), OPERATE_UPDATE, "enum.sheetAssemble.redPrepayment.name.payment_time", PaymentSheetEnum.PAYMENT_TIME.getShowType()),
        FUND_ACCOUNT(PaymentSheetEnum.FUND_ACCOUNT.getAttr(), PaySheetEnum.FUND_ACCOUNT.getAttr(), OPERATE_UPDATE, "enum.sheetAssemble.redPrepayment.name.fund_account", PaymentSheetEnum.FUND_ACCOUNT.getShowType()),
        ;
        /**
         * 回款单字段英文名
         */
        private String attrPaymentSheet;
        /**
         * 付款单字段英文名
         */
        private String attrPaySheet;
        /**
         * 1要移除，2修改（可能名称、是否必填等要修改）
         */
        private Integer operate;
        /**
         * 字段名
         */
        private String name;
        /**
         * 字段在各个界面（新建、编辑、列表、详情）的展现形式
         * 详见
         *
         * @see ShowTypeEnum
         */
        private Integer showType;

        RedPrepayment(String attrPaymentSheet, String attrPaySheet, Integer operate, String name, Integer showType) {
            this.attrPaymentSheet = attrPaymentSheet;
            this.attrPaySheet = attrPaySheet;
            this.operate = operate;
            this.name = name;
            this.showType = showType;
        }

        public String getName() {
            return I18nMessageUtil.getMessage(name);
        }

        /**
         * 得到要移除的字段名
         * @return java.util.List<java.lang.String>
         * @author zcp
         * @date 19/11/13 013 21:52
         * @update 19/11/13 013 21:52
         * @since v1.0
         * @version v1.0
         */
        public static List<String> removeAttr(XbbRefTypeEnum xbbRefTypeEnum) {
            List<String> removeAttrList = new ArrayList<>();
            if (Objects.equals(xbbRefTypeEnum, XbbRefTypeEnum.PAY_SHEET)) {
                for (RedPrepayment cache : values()) {
                    if (Objects.equals(cache.operate, OPERATE_REMOVE) && !Objects.equals(cache.attrPaySheet, "")) {
                        removeAttrList.add(cache.attrPaySheet);
                    }
                }
            } else {
                for (RedPrepayment cache : values()) {
                    if (Objects.equals(cache.operate, OPERATE_REMOVE)) {
                        removeAttrList.add(cache.attrPaymentSheet);
                    }
                }
            }
            return removeAttrList;
        }
        /**
         * 得到要更新的字段对应关系map
         * @return java.util.Map<java.lang.String,com.xbongbong.saas.enums.SheetAssembleEnum.RedPrepayment>
         * @author zcp
         * @date 19/11/14 014 10:19
         * @update 19/11/14 014 10:19
         * @since v1.0
         * @version v1.0
         */
        public static Map<String, RedPrepayment> updateAttr(XbbRefTypeEnum xbbRefTypeEnum) {
            //attrPaymentSheet-要更新的字段枚举
            Map<String, RedPrepayment> updateMap = new HashMap<>(values().length);
            if (Objects.equals(xbbRefTypeEnum, XbbRefTypeEnum.PAY_SHEET)) {
                for (RedPrepayment cache : values()) {
                    if (Objects.equals(cache.operate, OPERATE_UPDATE)) {
                        updateMap.put(cache.attrPaySheet, cache);
                    }
                }
            } else {
                for (RedPrepayment cache : values()) {
                    if (Objects.equals(cache.operate, OPERATE_UPDATE)) {
                        updateMap.put(cache.attrPaymentSheet, cache);
                    }
                }
            }
            return updateMap;
        }
    }

    /**
     * 坏账
     */
    public @Getter enum BadPayment {
        // 关联应收款不能修改
        PAYMENT(PaymentSheetEnum.PAYMENT.getAttr(), PaySheetEnum.PAY_PLAN.getAttr(), OPERATE_UPDATE, "enum.paymentSheet.attrName.payment", "enum.paySheet.attrName.pay_plan", PaymentSheetEnum.PAYMENT.getShowType()),
        // 坏账，移除字段：收款账户、支付方式
        FUND_ACCOUNT(PaymentSheetEnum.FUND_ACCOUNT.getAttr(), PaySheetEnum.FUND_ACCOUNT.getAttr(), OPERATE_REMOVE, null, null, null),
        PAY_METHOD(PaymentSheetEnum.PAY_METHOD.getAttr(), PaySheetEnum.PAY_TYPE.getAttr(), OPERATE_REMOVE, null, null, null),
        //修改字段信息
        AMOUNT(PaymentSheetEnum.AMOUNT.getAttr(), PaySheetEnum.AMOUNT.getAttr(), OPERATE_UPDATE, "enum.sheetAssemble.badPayment.name.amount", "enum.sheetAssemble.badPayment.namePay.amount", PaymentSheetEnum.AMOUNT.getShowType()),
        PAYMENT_TIME(PaymentSheetEnum.PAYMENT_TIME.getAttr(), PaySheetEnum.REAL_PAY_TIME.getAttr(), OPERATE_UPDATE, "enum.sheetAssemble.badPayment.name.payment_time", "enum.sheetAssemble.badPayment.namePay.payment_time", PaymentSheetEnum.PAYMENT_TIME.getShowType()),
        ;
        /**
         * 回款单字段英文名
         */
        private String attrPaymentSheet;
        /**
         * 付款单字段英文名
         */
        private String attrPaySheet;
        /**
         * 1要移除，2修改（可能名称、是否必填等要修改）
         */
        private Integer operate;
        /**
         * 字段名
         */
        private String name;
        /**
         * 付款单内的字段名
         */
        private String namePay;
        /**
         * 字段在各个界面（新建、编辑、列表、详情）的展现形式
         * 详见
         *
         * @see ShowTypeEnum
         */
        private Integer showType;

        BadPayment(String attrPaymentSheet, String attrPaySheet, Integer operate, String name, String namePay, Integer showType) {
            this.attrPaymentSheet = attrPaymentSheet;
            this.attrPaySheet = attrPaySheet;
            this.name = name;
            this.namePay = namePay;
            this.operate = operate;
            this.showType = showType;
        }

        public String getName() {
            return I18nMessageUtil.getMessage(name);
        }

        public String getNamePay() {
            return I18nMessageUtil.getMessage(namePay);
        }

        /**
         * 得到要移除的字段名
         * @return java.util.List<java.lang.String>
         * @author zcp
         * @date 19/11/13 013 21:52
         * @update 19/11/13 013 21:52
         * @since v1.0
         * @version v1.0
         */
        public static List<String> removeAttr(XbbRefTypeEnum xbbRefTypeEnum) {
            List<String> removeAttrList = new ArrayList<>();
            if (Objects.equals(xbbRefTypeEnum, XbbRefTypeEnum.PAY_SHEET)) {
                for (BadPayment cache : values()) {
                    if (Objects.equals(cache.operate, OPERATE_REMOVE)) {
                        removeAttrList.add(cache.attrPaySheet);
                    }
                }
            } else {
                for (BadPayment cache : values()) {
                    if (Objects.equals(cache.operate, OPERATE_REMOVE)) {
                        removeAttrList.add(cache.attrPaymentSheet);
                    }
                }
            }
            return removeAttrList;
        }
        /**
         * 得到要更新的字段对应关系map
         * @return java.util.Map<java.lang.String,com.xbongbong.saas.enums.SheetAssembleEnum.BadPayment>
         * @author zcp
         * @date 19/11/14 014 10:19
         * @update 19/11/14 014 10:19
         * @since v1.0
         * @version v1.0
         */
        public static Map<String, BadPayment> updateAttr(XbbRefTypeEnum xbbRefTypeEnum) {
            //attrPaymentSheet-要更新的字段枚举
            Map<String, BadPayment> updateMap = new HashMap<>(values().length);
            if (Objects.equals(xbbRefTypeEnum, XbbRefTypeEnum.PAY_SHEET)) {
                for (BadPayment cache : values()) {
                    if (Objects.equals(cache.operate, OPERATE_UPDATE)) {
                        updateMap.put(cache.attrPaySheet, cache);
                    }
                }
            } else {
                for (BadPayment cache : values()) {
                    if (Objects.equals(cache.operate, OPERATE_UPDATE)) {
                        updateMap.put(cache.attrPaymentSheet, cache);
                    }
                }
            }
            return updateMap;
        }
    }



    /**
     * 红冲其他收入单/其他支出单，即红冲已收款/红冲已付款，没有需要移除的字段。
     * 且这两种类型回款单在新建编辑时展示的字段完全一致，因此这两种类型回款单只建一个枚举
     */
    public @Getter enum RedOther {
        //关联原始收入单/关联原始支出单，显示到新建、编辑、详情
        ORIGIN_ID(OtherIncomeEnum.ORIGIN_ID.getAttr(), OtherExpenseEnum.ORIGIN_ID.getAttr(), OPERATE_UPDATE, "enum.otherIncome.attrName.origin_id", "enum.otherExpense.attrName.origin_id", ShowTypeEnum.EDIT_DETAIL.getCode()),
        // 红冲已核销、红冲预收款核销，名称修改
        AMOUNT(OtherIncomeEnum.AMOUNT.getAttr(), OtherExpenseEnum.AMOUNT.getAttr(), OPERATE_UPDATE, "enum.sheetAssemble.redOther.name.amount", "enum.sheetAssemble.redOther.nameExpense.amount", OtherIncomeEnum.AMOUNT.getShowType()),
        OTHER_TIME(OtherIncomeEnum.INCOME_TIME.getAttr(), OtherExpenseEnum.EXPENSE_TIME.getAttr(), OPERATE_UPDATE, "enum.sheetAssemble.redOther.name.income_time", "enum.sheetAssemble.redOther.nameExpense.expense_time", OtherIncomeEnum.INCOME_TIME.getShowType()),
        FUND_ACCOUNT(OtherIncomeEnum.FUND_ACCOUNT.getAttr(), OtherExpenseEnum.FUND_ACCOUNT.getAttr(), OPERATE_UPDATE, "enum.sheetAssemble.redOther.name.fund_account", "enum.sheetAssemble.redOther.nameExpense.fund_account", OtherIncomeEnum.FUND_ACCOUNT.getShowType()),
        ;
        /**
         * 其他收入单字段英文名
         */
        private String attrOtherIncome;
        /**
         * 其他支出单字段英文名
         */
        private String attrOtherExpense;
        /**
         * 1要移除，2修改（可能名称、是否必填等要修改）
         */
        private Integer operate;
        /**
         * 字段名
         */
        private String name;
        /**
         * 其他支出单内的字段名
         */
        private String nameExpense;
        /**
         * 字段在各个界面（新建、编辑、列表、详情）的展现形式
         * 详见
         *
         * @see ShowTypeEnum
         */
        private Integer showType;

        RedOther(String attrOtherIncome, String attrOtherExpense, Integer operate, String name, String nameExpense, Integer showType) {
            this.attrOtherIncome = attrOtherIncome;
            this.attrOtherExpense = attrOtherExpense;
            this.name = name;
            this.nameExpense = nameExpense;
            this.operate = operate;
            this.showType = showType;
        }

        public String getName() {
            return I18nMessageUtil.getMessage(name);
        }

        public String getNameExpense() {
            return I18nMessageUtil.getMessage(nameExpense);
        }
        /**
         * 得到要更新的字段对应关系map
         * @return java.util.Map<java.lang.String,com.xbongbong.saas.enums.SheetAssembleEnum.RedWriteOff>
         * @author zcp
         * @date 19/11/14 014 10:19
         * @update 19/11/14 014 10:19
         * @since v1.0
         * @version v1.0
         */
        public static Map<String, RedOther> updateAttr(XbbRefTypeEnum xbbRefTypeEnum) {
            //attrOtherIncome-要更新的字段枚举
            Map<String, RedOther> updateMap = new HashMap<>(values().length);
            if (Objects.equals(xbbRefTypeEnum, XbbRefTypeEnum.PAY_SHEET)) {
                for (RedOther cache : values()) {
                    if (Objects.equals(cache.operate, OPERATE_UPDATE)) {
                        updateMap.put(cache.attrOtherExpense, cache);
                    }
                }
            } else {
                for (RedOther cache : values()) {
                    if (Objects.equals(cache.operate, OPERATE_UPDATE)) {
                        updateMap.put(cache.attrOtherIncome, cache);
                    }
                }
            }
            return updateMap;
        }
    }
}
